package xaj.scc.ast;

import polyglot.ast.Node;
import polyglot.ext.jl.ast.Node_c;
import polyglot.util.CodeWriter;
import polyglot.util.Position;
import polyglot.visit.NodeVisitor;
import polyglot.visit.PrettyPrinter;

public class ClosureFactor_c extends Node_c implements ClosureFactor {

	private Factor factor;

	public ClosureFactor_c(Position pos, Factor factor) {
		super(pos);
		this.factor = factor;
	}

	public Factor getFactor() {
		return factor;
	}

	public ClosureFactor setFactor(Factor factor) {
		ClosureFactor_c n = (ClosureFactor_c) copy();
		n.factor = factor;
		return n;
	}

	protected ClosureFactor_c reconstruct(Factor f) {
		if (factor != f) {
			ClosureFactor_c n = (ClosureFactor_c) copy();
			n.factor = f;
			return n;
		}
		return this;
	}

	public Node visitChildren(NodeVisitor v) {
		Factor factor = (Factor) this.factor.visit(v);

		return reconstruct(factor);
	}

	public void prettyPrint(CodeWriter w, PrettyPrinter tr) {
		w.write("{");
		factor.prettyPrint(w, tr);
		w.write("}");
	}

	@Override
	public void accept(Visitor v) {
		v.visitClosureFactor(this);
		
	}
}
